<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- html片段 -->
<form id="update_password_form" action="user/password/update"
	method="post">
	<div id="update_password_tip"></div>
	<div class="p20">
		<p class="h30 lh28">
			原来密码：<input type="password" id="oldpassword" name="oldpassword"
				class="easyui-validatebox" data-options="required:true" />
		</p>
		<p class="h30 lh28">
			新的密码：<input type="password" id="newpassword" name="newpassword"
				class="easyui-validatebox" data-options="required:true" />
		</p>
		<p class="h30 lh28">
			确认密码：<input type="password" name="twopassword"
				class="easyui-validatebox" required="required"
				validType="equals['#newpassword']" />
		</p>
	</div>
</form>
<!-- javascript -->
<script type="text/javascript">
	//扩展验证规则
	$.extend($.fn.validatebox.defaults.rules, {
		equals : {
			validator : function(value, param) {
				console.debug(value + ":" + $(param[0]).val());
				return value == $(param[0]).val();
			},
			message : '2次密码输入不相同'
		}
	});

	//验证原来的密码是否正确
	function check_oldpassword(){
		var flag = false;
		$.ajax({
			type : "POST",
			url : "user/password/check",
			data : "oldpassword="+$('#oldpassword').val(),
			async:false,
			success : function(msg) {
				if(msg=="success"){
					flag = true;
				}else{
					$('#update_password_tip').html('<span style="color:red;">旧密码不正确</span>');
				}
			}
		});
		return flag;
	}
</script>